<?php $this->beginWidget('webroot.widgets.iButtonBar');?>

<?php $this->widget('bootstrap.widgets.TbButton', array(
    'label'=>UserModule::t('Create User'),
    'type'=>'success',
	'icon'=>'plus-sign white',
    'url'=> array('create'),
));?>
<?php $this->widget('bootstrap.widgets.TbButton', array(
    'label'=>UserModule::t('Advanced Search'),
    'type'=>'primary',
    'url'=> '#',
	'icon'=>'search white',
	'htmlOptions'=>array('class'=>'search-button')
));?>
<?php $this->endWidget();?>
<?php

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});	
$('.search-form form').submit(function(){
    $.fn.yiiGridView.update('user-grid', {
        data: $(this).serialize()
    });
    return false;
});
");

?>

<div class="search-form" style="display:none">
<?php $this->beginWidget('webroot.widgets.iPortlet', array('title'=>UserModule::t('Advanced Search')));?>
<?php $this->renderPartial('_search',array(
    'model'=>$model,
)); ?>
<?php $this->endWidget();?>
</div><!-- search-form -->

<?php $this->widget('webroot.widgets.iGridView', array(
	'id'=>'user-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name' => 'id',
			'type'=>'raw',
			'value' => 'CHtml::link(CHtml::encode($data->id),array("admin/update","id"=>$data->id))',
			'htmlOptions'	=>	array(
				'width'	=>	'50',
				'align'	=>	'center',
			),
		),
		array(
			'name' => 'username',
			'type'=>'raw',
			'value' => 'CHtml::link(UHtml::markSearch($data,"username"),array("admin/view","id"=>$data->id))',
		),
		array(
			'name'=>'email',
			'type'=>'raw',
			'value'=>'CHtml::link(UHtml::markSearch($data,"email"), "mailto:".$data->email)',
		),
		'create_at',
		'lastvisit_at',
		array(
			'name'=>'superuser',
			'value'=>'User::itemAlias("AdminStatus",$data->superuser)',
			'filter'=>User::itemAlias("AdminStatus"),
			'htmlOptions'	=>	array(
				'width'	=>	'100',
				'align'	=>	'center',
			),
		),
		array(
			'name'=>'status',
			'value'=>'User::itemAlias("UserStatus",$data->status)',
			'filter' => User::itemAlias("UserStatus"),
		),
		array(
			'class'=>'webroot.widgets.iButtonColumn',
			'htmlOptions'=>array('style'=>'width: 50px'),
		),
	),
)); ?>